package com.cmiov.pulsar.pulsardemo;

import org.apache.pulsar.functions.api.Context;
import org.apache.pulsar.functions.api.Function;

/**
 * * Licensed to CMDT,Inc. under the terms of the CMDT
 * Software License version 1.0.
 * <p>
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 * ----------------------------------------------------------------------------
 * Date           Author               Version        Comments
 * 18-12-26       joe chow                 1.0            Initial Version
 */
public class UserCount implements Function<User, Long> {

    @Override
    public Long process(User input, Context context) throws Exception {
        context.incrCounter(input.getName(), 1);

        return context.getCounter(input.getName());
    }
}
